<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>智慧工地</title>
		<link rel="stylesheet" href="../../../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../../css/icons-extra.css" />
		<link rel="stylesheet" type="text/css" href="../../../css/master.css" />
		<link rel="stylesheet" type="text/css" href="../../../css/news-list.css" />
		<link rel="stylesheet" type="text/css" href="../../../css/refresh.css" />
		<!--上拉刷新 下拉加载样式-->
		<link rel="stylesheet" type="text/css" href="../../../css/mui.picker.min.css" />
	</head>
	<body>
		<header class="mui-bar mui-bar-nav mui-head bg-00BC8D">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title text-ffffff">修改用户</h1>
		</header>
		<div class="mui-content" id="app">
			<div class="mui-popover-arrow"></div>
			<div class="mui-table-view-cell mui-media" style="text-align: center;">
					<a class="zxxq" href="javascript:;">
						<div class="mui-media-body">
							<div class="mui-row" style="margin-top: 15px;">
								<p style="height: 30px;line-height: 30px;font-size: 16px;width:70px;text-align:right;color: #555555;display: inline-block;">用户名:</p>
								<div style="display: inline-block; width: 170px;">
									<input type="text" v-model="items.username" placeholder="请输入用户名..." style="padding: 5px;height: 30px;">
								</div>
							</div>
							<div class="mui-row">
								<p style="height: 30px;line-height: 30px;font-size: 16px;width:70px;text-align:right;color: #555555;display: inline-block;">密码:</p>
								<div style="display: inline-block; width: 170px;">
									<input type="text" v-model="items.password" placeholder="请输入密码..." style="padding: 5px;height: 30px;">
								</div>
							</div>
							<div class="mui-row">
								<button @click="userUpdata" type="button" class="mui-btn bg-00BC8D text-ffffff" style="height: 30px;border:1px solid #00BC8D;line-height: 10px;">确认</button>
							</div>
						</div>
					</a>
				</div>
		</div>
	</body>
	<script src="../../../js/jquery.min.js"></script>
	<script src="../../../js/mui.min.js"></script>
	<script src="../../../libs/waitMe/waitMe.min.js"></script>
	<script src="../../../js/setting.js"></script>
	<script src="../../../js/common.js"></script>
	<script src="../../../js/vue.min.js"></script>
	<script>
		var h = mui(document).common();
		var userid=localStorage.getItem("userId");
		
		var app = new Vue({
			el: '#app',
			data: {
				items: {}
			},
			methods: {
				userUpdata: function(){
					userUpdata();
				}
			}
		})
		
		mui.plusReady(function() { //如果需要调用plus
			searchList(userid); //初始化
		});
		
		//查询页面
		function searchList(id) {
			var xhr = null;
			var url = setting.ip + "user/v1/getUser";
			var data = {
				"id": id
			};
			xhr = new plus.net.XMLHttpRequest();
			xhr.open("POST", url);
			xhr.setRequestHeader('Content-Type', 'application/json');
			xhr.send(JSON.stringify(data));
			xhr.onreadystatechange = function() {
				if(xhr.readyState == 4) {
					if(xhr.status == 200) {
						app.items = eval('(' + xhr.responseText + ')').obj;
					}
				}
			}
		}
		
		//修改用户
		function userUpdata(){
			var xhr = null;
			var url = setting.ip + "user/v1/updateuser";
			var data = {
				"id":app.items.id,
				"username":app.items.username,
				"password":app.items.password
			};
			xhr = new plus.net.XMLHttpRequest();
			xhr.open("POST", url);
			xhr.setRequestHeader('Content-Type', 'application/json');
			xhr.send(JSON.stringify(data));
			xhr.onreadystatechange = function() {
				if(xhr.readyState == 4) {
					if(xhr.status == 200) {
						mui.toast("修改用户成功!");
						setTimeout(function(){
							var taskList = plus.webview.getWebviewById('userControl');
							taskList.reload();
							mui.back();
						},1000);
					}
				}
			}
		}
	</script>
</html>
